package com.example.stuwork.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 阿里云OSS配置
 */
@Configuration
public class OSSConfig {

    /**
     * 地域节点
     */
    @Value("${aliyun.oss.endpoint}")
    private String endpoint;

    /**
     * 访问ID
     */
    @Value("${aliyun.oss.accessKeyId}")
    private String accessKeyId;

    /**
     * 访问密钥
     */
    @Value("${aliyun.oss.accessKeySecret}")
    private String accessKeySecret;

    /**
     * 存储空间
     */
    @Value("${aliyun.oss.bucketName}")
    private String bucketName;

    /**
     * URL前缀
     */
    @Value("${aliyun.oss.urlPrefix}")
    private String urlPrefix;

    /**
     * 目录前缀
     */
    @Value("${aliyun.oss.dir.prefix}")
    private String dirPrefix;

    /**
     * 最大文件大小（MB）
     */
    @Value("${aliyun.oss.maxSize:10}")
    private Integer maxSize;

    /**
     * 创建OSS客户端实例
     */
    @Bean
    public OSS ossClient() {
        return new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
    }

    public String getEndpoint() {
        return endpoint;
    }

    public String getAccessKeyId() {
        return accessKeyId;
    }

    public String getAccessKeySecret() {
        return accessKeySecret;
    }

    public String getBucketName() {
        return bucketName;
    }

    public String getUrlPrefix() {
        return urlPrefix;
    }

    public String getDirPrefix() {
        return dirPrefix;
    }

    public Integer getMaxSize() {
        return maxSize;
    }
} 